<template>
    <view style="padding: 10upx 20upx;">
        <view class="enter"> 
            <view class="enter_title">企业信息</view>
            <!-- 注意，如果需要兼容微信小程序，最好通过setRules方法设置rules规则 -->
            <u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm" labelWidth="auto" :labelStyle="{fontSize:'12px'}">
                <u-form-item label="企业名称" prop="qiye_name" >
                    <u--input v-model="formData.qiye_name" border="none"></u--input>
                </u-form-item>
                <u-form-item label="负责人姓名" prop="user_name" >
                    <u--input v-model="formData.user_name" border="none"></u--input>
                </u-form-item>
                <u-form-item label="职务" prop="user_title" >
                    <u--input v-model="formData.user_title" border="none"></u--input>
                </u-form-item>
                <u-form-item label="联系电话" prop="user_phone" >
                    <u--input v-model="formData.user_phone" border="none"></u--input>
                </u-form-item>
                <u-form-item label="省市" prop="area_id" >
                    <u--input v-model="formData.area_id" border="none"></u--input>
                </u-form-item>
                <u-form-item label="企业注册资金" prop="balance" >
                    <u--input v-model="formData.balance" border="none"></u--input>
                </u-form-item>
                <u-form-item label="企业年收入" prop="qiye_year_balance" >
                    <u--input v-model="formData.qiye_year_balance" border="none"></u--input>
                </u-form-item>
                <u-form-item label="所属行业赛道" prop="saidao_id" >
                    <u--input v-model="formData.saidao_id" border="none"></u--input>
                </u-form-item>
            </u--form>
        </view>
        <view class="enter">
            <view class="enter_title">补充内容</view>
            <!-- 注意，如果需要兼容微信小程序，最好通过setRules方法设置rules规则 -->
            <u--textarea v-model="formData.mark" placeholder="请输入内容" border></u--textarea>
            <view>
                <view class="enter_label">上传资料（营业执照、名片等）</view>
                <u-upload name="1" multiple :maxCount="1" v-model="formData.images"></u-upload>
            </view>
            
        </view>
        <view class="custom" >
            <u-button  type="primary" shape="circle" @click="handlesubmit">提交</u-button>
        </view>
       
    </view>
</template>

<script>
export default {
    data() {
        return {
            showSex: false,
            formData: {
                qiye_name: '',
                user_name: '',
                user_title:'',
                user_phone:'',
                area_id:'',
                balance:'',
                qiye_year_balance:'',
                saidao_id:'',
                mark:'',
                images:''
            },
            value1: '',
            rules: {
                'qiye_name': {
                    type: 'string',
                    required: true,
                    message: '请填写企业名称',
                    trigger: ['blur', 'change']
                },
                'user_name': {
                    type: 'string',
                    required: true,
                    message: '请填写负责人姓名',
                    trigger: ['blur', 'change']
                },
                'user_title': {
                    type: 'string',
                    
                    required: true,
                    message: '请填写职务',
                    trigger: ['blur', 'change']
                },
                'user_phone': {
                    type: 'string',
                    
                    required: true,
                    message: '请填写联系电话',
                    trigger: ['blur', 'change']
                },
                'area_id': {
                    type: 'string',
                    
                    required: true,
                    message: '请选择地区',
                    trigger: ['blur', 'change']
                },
                'balance': {
                    type: 'string',
                    
                    required: true,
                    message: '请填写企业注册资金',
                    trigger: ['blur', 'change']
                },
                'qiye_year_balance': {
                    type: 'string',
                    
                    required: true,
                    message: '请填写企业年收入',
                    trigger: ['blur', 'change']
                },
                'saidao_id': {
                    type: 'string',
                    
                    required: true,
                    message: '请填写所属赛道',
                    trigger: ['blur', 'change']
                },
            },
            radio: '',
            switchVal: false,
            id:undefined
        };
    },
    methods: {
        async handlesubmit(){
            let res
            if(this.id){
                res = this.$api.componyShenqing({ ...this.formData,id:this.id })
                
            }else{
                res = this.$api.componyEnter({ ...this.formData })
            }
            global.showToast('入驻成功')
            uni.navigateBack({
                delta: 1,
            });

        }
    },
    onLoad() {
        //如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
        this.$refs.uForm.setRules(this.rules)
        const eventChannel = this.getOpenerEventChannel();
        eventChannel.on('acceptDataFromSourcePage',  (data) => {
            this.formData = {
                qiye_name: data.param.qiye_name,
                user_name: data.param.user_name,
                user_title:data.param.user_title,
                user_phone:data.param.user_phone,
                area_id:data.param.area_id,
                balance:data.param.balance,
                qiye_year_balance:data.param.qiye_year_balance,
                saidao_id:data.param.saidao_id,
                mark:data.param.mark,
                images:data.param.images,
            }
            this.id = data.param.id
        });
    },
};
</script>
<style scoped lang="scss">
.enter{
background: #FFFFFF;
box-shadow: 0px 6px 16px 0px rgba(0,0,0,0.1);
border-radius: 8upx;
padding: 20upx;
.enter_title{
    padding-bottom: 20upx;
    border-bottom:1px solid #f0f0f0 ;
}
.enter_label{
    font-size: 20upx;
    margin-bottom: 10upx;
}
}
.custom{
    margin-top: 20upx;
}
</style>
